#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
struct node {
    bool leaf;
    node* next[10];
};
void creat_node(node* &root) {
    root=new node();
    root->leaf=true;
    for (int i=0; i<10; i++) root->next[i]=NULL;
}
bool insert(node* &tmp, char *a) {
    int len = strlen(a);
    bool flag=false;
    bool creat=false;
    for (int i=0; i<len; i++) {
        if (tmp->leaf==false) {
            if (i==len-1) flag=true;
            cout<<a[i]-'0'<<endl;
            tmp=tmp->next[a[i]-'0'];
            if (tmp==NULL) {
                creat=true;
                creat_node(tmp);
                cout<<"creat:"<<creat<<endl;
            }
        }
        else {
            if (creat==false)flag=true;
            tmp->leaf=false;
            tmp=tmp->next[a[i]-'0'];
            creat_node(tmp);
        }
    }
    cout<<endl;
    return flag;
}
void del(node* &root) {
    if (root==NULL) return;
    for (int i=0; i<10; i++) {
        del(root->next[i]);
    }
    delete root;
}
int main() {
    int T;
    cin>>T;
    node *tree;
    bool flag;
    int n;
    while (T--) {
        cin>>n;
        creat_node(tree);
        tree->leaf=false;
        flag=false;
        for (int i=0; i<n; i++) {
            char s[12];
            scanf("%s",s);
            node *tmp=tree;
            if(insert(tmp,s)) flag=true;
        }
        if (flag) cout<<"NO"<<endl;
        else cout<<"YES"<<endl;
        del(tree);
    }
    return 0;
}
